package com.citi.gts.galto.modules.validation.rule.impl;

import com.citi.gts.galto.constant.key.RejectionKey;
import com.citi.gts.galto.core.tools.exception.ReferenceException;
import com.citi.gts.galto.core.tools.factory.InvalidConfigurationException;
import com.citi.gts.galto.core.tools.reference.Rejection;
import com.citi.gts.galto.core.tools.reference.impl.RejectionReference;
import com.citi.gts.galto.modules.validation.FieldReference;
import com.citi.gts.galto.modules.validation.rule.Verifiable;
import com.citi.gts.galto.modules.validation.vo.Repair;
import org.springframework.beans.factory.annotation.Required;

import javax.annotation.Resource;
import java.util.List;

public abstract class LeafRule implements Verifiable {

    protected Repair repair;

    @Resource
    protected FieldReference fieldReference;

    @Resource
    protected RejectionReference<RejectionKey> rejectionReference;

    public abstract void setFieldsValidated() throws ReferenceException;

    @Required
    public void setRejectionCode(String rejectionCode) throws InvalidConfigurationException {

        RejectionKey rejectionKey = new RejectionKey(rejectionCode);

        Rejection rejection = rejectionReference.find(rejectionKey);

        repair = new Repair();
        repair.setRejection(rejection);

    }
}